package cn.pink.core.support.serializer;

import org.nustaq.serialization.FSTConfiguration;

/**
 * FST 序列化 反序列化
 * @Author: pink
 * @Date: 2022/8/30 20:16
 */
public class FSTSerializer {
    private FSTConfiguration conf ;

    public FSTSerializer() {
        conf = FSTConfiguration.getDefaultConfiguration();
        conf.setClassLoader(Thread.currentThread().getContextClassLoader());
    }

    public byte[] serialize(Object obj) {
        return conf.asByteArray(obj);
    }

    public Object deserialize(byte[] bytes) {
        return conf.asObject(bytes);
    }
}
